package com.flca.frw.components
{
	import com.flca.frw.interfaces.ICrudCtlr;
	import flash.display.DisplayObject;
	import mx.containers.VBox;
	import mx.containers.Panel;
	import mx.controls.Alert;
	import com.flca.frw.interfaces.ISimpleCtlr;
	import com.flca.frw.components.SimpleBaseCtrl;
	import mx.controls.Button;
	import mx.collections.ArrayCollection;
	import com.flca.frw.interfaces.IModel;
	
	public class LookupCtrl extends Panel 
	{
		[Inspectable]
		public var onSelectClicked : Function;
		
		[Inspectable]
		public var onCancelClicked : Function;

		[Inspectable]
		public var lookupValues : ArrayCollection;
		
		[Inspectable]
		public var gridFormatter : IModel;

		/*
		This method should called after al the properties from above are set.
		*/
		public function init() : void {
			view.idLookupValues.dataProvider = lookupValues;
			if (gridFormatter != null && gridFormatter.getLookupColumns() != null) {
				view.idLookupValues.columns = gridFormatter.getLookupColumns();			
			}
		}
		
		public function close():void {		
		}
		
		public function getDisplayName():String {
			return "";
		}
		
		public function getInitialHash():int {
			return 0;
		}
		
		public function getCallbackReadyForClose():Function {
			return null;
		}

		public function getCallbackSaveComplete():Function {
			return null;
		}
		
		private function get view() : LookupForm {
			return this as LookupForm;
		}
		
        protected function cancelClicked():void {
			if (onCancelClicked != null) {
				onCancelClicked();
			} else {
				Alert.show("onCancelClicked not assigned!");
			}
        }
        
        protected function selectClicked():void {
			if (onSelectClicked != null) {
				onSelectClicked();
			} else {
				Alert.show("onSelectClicked not assigned!");
			}
        }
		
	}
}